<template>
  <div class="app-container">
    <el-card style="width: 70%;">
      <el-row :gutter="20">
        <el-col :span="18">
          <h2 >销售退货单号: {{ this.form.srCode }}</h2>
        </el-col>
        <el-col :span="6" style="text-align: right;">
          <el-button type="primary" @click="DetailClose()">关闭</el-button>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <p><span>制单人：</span>{{ this.form.createBy }}</p>
        </el-col>
        <el-col :span="6">
          <p><span>所在部门：</span>{{ this.form.createDept }}</p>
        </el-col>
        <el-col :span="6">
          <p><span>制单时间：</span>{{ parseTime(this.form.createTime,'{y}-{m}-{d}') }}</p>
        </el-col>
        <el-col :span="4">
          <p>
            <span >单据状态：</span>
            <dict-tag :options="dict.type.py_status" :value="this.form.srState" style="font-weight: bold"/>
          </p>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <p><span>客户名称：</span>{{ this.form.customer }}</p>
        </el-col>
        <el-col :span="6">
          <p><span>联系人：</span>{{ this.form.contacts }}</p>
        </el-col>
        <el-col :span="6">
          <p><span>联系方式：</span>{{ this.form.phone }}</p>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <p><span>销售部门：</span>{{ this.form.saleDept }}</p>
        </el-col>
        <el-col :span="6">
          <p><span>销售负责人：</span>{{ this.form.salePerson }}</p>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5">
          <p><span>退货原因：</span>{{ this.form.rejectedReason }}</p>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="5">
          <p><span>备注：</span>{{ this.form.remark }}</p>
        </el-col>
      </el-row>
    </el-card>
    <el-card style="width: 70%;margin-top: 20px">
      <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
        <el-menu-item index="1">其他信息</el-menu-item>
        <el-menu-item index="2" >销售退货明细</el-menu-item>
      </el-menu>
      <div v-if="activeIndex==='1'">
        <h2>附件</h2>
        <ul class="file-list">
          <li
            v-for="file in fileList"
          ><a :href="file.filePath">{{file.fileName}}</a></li>
        </ul>
      </div>
      <div v-if="activeIndex==='2'">
        <el-table
          :data="tableData"
          style="width: 100%;margin-top: 20px">
          <el-table-column
            prop="productName"
            label="货品名称"
            width="180"
            fixed="left"
          >
          </el-table-column>
          <el-table-column
            prop="productCode"
            label="货品编号"
            width="180">
          </el-table-column>
          <el-table-column
            prop="productType"
            label="货品类型">
          </el-table-column>
          <el-table-column
            prop="productModel"
            label="规格型号">
          </el-table-column>
          <el-table-column
            prop="unit"
            label="单位">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.py_product_unit" :value="scope.row.unit" style="font-weight: bold"/>
            </template>
          </el-table-column>
          <el-table-column
            prop="saleNum"
            label="销售数量">
          </el-table-column>
          <el-table-column
            prop="total"
            label="累计退货数量"
            width="150px"
          >
          </el-table-column>
          <el-table-column
            prop="rejectedNum"
            label="本次退货数量"
            width="150px"
          >
          </el-table-column>
          <el-table-column
            prop="salePrice"
            label="销售单价">
          </el-table-column>
          <el-table-column
            prop=""
            label="退货金额">
            <template slot-scope="scope">
              {{Number(scope.row.rejectedNum*scope.row.salePrice)}}
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-card>
  </div>
</template>
<script>
import {parseTime} from "../../../../utils/ruoyi";
import {getInfo} from "@/api/rejected/rejected"
export default {
  name: "rejected",
  dicts: ['py_status','py_product_unit'],
  data() {
    return {
      tableData:[],
      fileList:[],
      activeIndex: '1',
      form:{

      }
    };
  },
  created() {
    this.form=this.$route.query.rejected;
    console.log("form",this.form)
    getInfo(this.form.srCode).then(re=>{
      console.log("detail",re)
      this.fileList=re.fileList;
      this.tableData=re.orderInfo;
    })
  },
  methods: {
    parseTime,
    DetailClose(){
      this.$router.push( {path:'/orders/rejected'});
    },
    handleSelect(key, keyPath) {
      this.activeIndex = key;
    }

  }
};
</script>


